package lumis.portal.progress;

import java.sql.Timestamp;
import java.util.Collection;

import lumis.portal.PortalException;
import lumis.portal.manager.ManagerException;

/**
 * Manager for Progress operations
 *
 * @version $Revision: 4942 $ $Date: 2006-11-03 09:10:15 -0300 (Fri, 03 Nov 2006) $
 * @since 4.0.7
 */
public class ProgressManager implements IProgressManager
{
	IProgressDao progressDao = new ProgressDaoJdbc();
	
	public void addOrUpdate(ProgressConfig progressConfig) throws ManagerException, PortalException
	{
		if (progressConfig.getType().equals(ProgressConfig.Type.STEP) || progressConfig.getType().equals(ProgressConfig.Type.ABORT))
			progressDao.addOrUpdateStep(progressConfig);
		else
			progressDao.add(progressConfig);
	}

	public void deleteByProcessId(String processId) throws ManagerException, PortalException
	{
		progressDao.deleteByProcessId(processId);
	}

	public void deleteExpired(Timestamp expirationDateTime) throws ManagerException, PortalException
	{
		progressDao.deleteExpired(expirationDateTime);
	}

	public Collection<ProgressConfig> getByProcessId(String processId, Timestamp startDateTime) throws ManagerException, PortalException
	{
		return progressDao.getByProcessId(processId, startDateTime);
	}
	
	public boolean getAbortedByProcessId(String processId) throws ManagerException, PortalException
	{
		return progressDao.getAbortedByProcessId(processId);
	}


}
